void setup() {
pinMode(PA15,INPUT_PULLUP);      //将PA15引脚设置为输入上拉模式  
pinMode(PC5,OUTPUT);            //将PC5引脚设置为输出模式
pinMode(PB0,OUTPUT);            //将PB0引脚设置为输出模式
pinMode(PB1,OUTPUT);            //将PB1引脚设置为输出模式
digitalWrite(PC5,HIGH);         //将PC5引脚初始化为高电平
digitalWrite(PB0,HIGH);         //将PB0引脚初始化为高电平
digitalWrite(PB1,HIGH);         //将PB1引脚初始化为高电平
}

void loop() {
if(digitalRead(PA15)==LOW)       //如果PA15引脚的电平为低电平
  {
  digitalWrite(PC5,LOW);        //将PC5引脚输出低电平   -->红灯亮  
  digitalWrite(PB0,LOW);        //将PB0引脚输出低电平   -->黄灯亮
  digitalWrite(PB1,LOW);        //将PB1引脚输出低电平   -->蓝灯亮
  }
else                            //否则
  {
  digitalWrite(PC5,HIGH);       //将PC5引脚输出高电平   -->红灯灭  
  digitalWrite(PB0,HIGH);       //将PB0引脚输出高电平   -->黄灯灭
  digitalWrite(PB1,HIGH);       //将PB1引脚输出高电平   -->蓝灯灭
  }
}
